﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LotteryVote.Logic.Web;
using LotteryVote.Logic;

namespace LotteryVote
{
    public partial class DropWaterLog : AuthorizePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txt_date.Text = DateTime.Today.ToShortDateString();
                BindDropWater(false);
            }
        }

        protected void btn_search_Click(object sender, EventArgs e)
        {
            BindDropWater(true);
        }

        void BindDropWater(bool search)
        {
            Execute(() =>
            {
                BetUpperLimitFacade limitFacade = new BetUpperLimitFacade();
                rpt_dropwater.DataSource = search ?
                    limitFacade.ListUpperLimitByCondition(DateTime.Parse(txt_date.Text), txt_num.Text, lv_company.SelectedValue, lv_gameplayway.GamePlayWayId)
                    .Where(it => it.DropValue > 0)
                    :
                    limitFacade.ListTodayUpperLimit().Where(it => it.DropValue > 0);
                rpt_dropwater.DataBind();
            });
        }
    }
}